/**
 * 0077
 *  
 * @Author : roryrywang
 * @DateTime : 2024/8/15 23:34
 */

#include <vector>
#include "iostream"

using namespace std;

class Solution {
public:
    vector<int> tmp;
    vector<vector<int>> res;

    void dfs(int n, int k, int x, int cnt) {
        if (cnt == k) {
            res.push_back(tmp);
            return;
        }
        for (int i = x + 1; i <= n; ++i) {
            tmp.push_back(i);
            dfs(n, k, i, cnt + 1);
            tmp.pop_back();
        }
    }

    vector<vector<int>> combine(int n, int k) {
        dfs(n, k, 0, 0);
        return res;
    }
};

int main() {
    Solution sl;
    vector<vector<int>> res = sl.combine(4, 2);
    for (vector<int> i: res) {
        for (int j: i) {
            printf("%d ", j);
        }
        printf("\n");
    }
    printf("\n");
    return 0;
}